package top.babyyan.base.entity;

import top.babyyan.base.constants.ResponseCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 功能模块-通用返回类
 * @author superbabyyan
 * @since 2024/9/3 9:57
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private int code;
    private String message;
    private T data;

    public static Result success(Object data){
        return new Result<>(ResponseCodeEnum.SUCCESS.getCode(),ResponseCodeEnum.SUCCESS.getMessage(),data);
    }

    public static Result fail(int code,String message){
        return new Result<>(code,message,null);
    }

    public static Result fail(String message) {
        return new Result(1, message, (Object)null);
    }


}
